Page 61 - 2629_Devagiri_C-7
P. 61
There should not be any space within the tag. For example, < T A G> is incorrect.
TAGS AND ATTRIBUTES
All container tags require a closing tag with a forward slash followed by the tag name.
Tags are HTML building blocks used to structure web content like headings, paragraphs, links and Tag names must be enclosed in angle brackets without spaces.
images. Enclosed in < >, each tag has a specific meaning interpreted by the browser. When nesting, the inner tag should be closed before closing the outer tag.
Syntax:
An attribute should be present in the opening tag.
<TAG_NAME> content </TAG_NAME>
For example:
STRUCTURE OF AN HTML5 DOCUMENT
<P> My cat is very grumpy </P>
The basic structure of an HTML document is as follows:
Opening Tag Content Closing Tag
<!DOCTYPE HTML>
Most HTML tags have opening and closing tags. The opening tag < > starts an element and the
closing tag </ > ends it. Together with the content, they form an element. <HTML>
<HEAD>
TYPES OF TAGS
<TITLE>Title of the web page</TITLE> Head Section
HTML5 tags can be classified into two types:
</HEAD>
Container Tags: Container tags have opening and closing tags that enclose data. The closing
tag has a forward slash. Examples include <P>…</P>, <HTML>…</HTML>, <HEAD>…</HEAD>, <BODY>
<BODY>…</BODY> and <H1>…</H1>.
Content of the Web page Body Section
Empty Tags: An empty tag is a tag that does not have a closing tag. It is used by itself to add
</BODY>
something to a web page. Examples of empty tags include <HR> and <BR>.
</HTML>
NESTING TAGS
THE <!DOCTYPE HTML> TAG
Nesting tags means placing one HTML tag inside another. Tags follow LIFO (Last In First Out):
the last opened tag must be closed first. All HTML5 documents start with <!DOCTYPE HTML>, telling the browser to interpret the document
as HTML5.
For example:
<BODY> <H1> Web Browser </H1> </BODY> THE <HTML> TAG
The <HTML> tag is the root of an HTML document. The <HTML> tag is the container tag for all other
ATTRIBUTE
HTML elements, except for the <!DOCTYPE HTML> declaration.
An attribute adds extra information to an HTML tag. It has a name and value, is placed in the
opening tag and the value is enclosed in quotes. THE <HEAD> TAG
Syntax: The <HEAD> tag contains metadata about the web page. It includes tags that provide information
about the web page but are not displayed directly on the page itself. Tags that can be placed
<TAG_NAME ATTRIBUTE_NAME="VALUE">...</TAG_NAME>
inside the <HEAD> tag include <TITLE>, <STYLE>, <SCRIPT> and <META>.
RULES FOR WRITING HTML5 CODE THE <TITLE> TAG
The <TITLE> tag is a container tag. It defines the title of the document. It can only contain text and
Some of the basic rules for writing HTML5 code are:
it is displayed on the web browser’s title bar or the page’s tab.
Content should be placed between opening and closing tags.
59
HTML5–Getting Started

